/**
 * tab
 */
var CustomTab = CustomToggle.extend({
    /**
     * 玩法列表节点
     */
    wanfaList: null,
    /**
     * panel列表
     */
    panelList: {},

    /**
     * 创建房间window
     */
    createRoomWinodw: null,

    ctor: function (_window) {
        this._super(_window);
        this.createRoomWinodw = _window;
        this.panelList = {};
    },

    onEnterTransitionDidFinish: function () {
        CustomToggle.prototype.onEnterTransitionDidFinish.call(this);
        this.scheduleUpdate();
    },

    update: function () {
        this.changeFocus();
    },

    changeFocus: function () {
        var self = this;
        _.forIn(self.normalImages, function (normalImage) {
            var normalImageObj = self.getNode(self.parentNode, normalImage);
            safeVisible(normalImageObj, !self.IsOn);
        });
        _.forIn(self.focusImages, function (focusImage) {
            var focusImageObj = self.getNode(self.parentNode, focusImage);
            safeVisible(focusImageObj, self.IsOn);
        });
        for (var i = 0; i < self.dependObjects.length; i++) {
            var className = _.last(self.dependObjects[i].split('.'));
            if (window[className]) {
                if (!self.panelList[className]) {
                    self.panelList[className] = new window[className]();
                    var wanfaObj = self.getNode(self.parentNode, self.wanfaList);
                    wanfaObj.addChild(self.panelList[className]);
                    if (this.createRoomWinodw._wanFaList && this.createRoomWinodw._wanFaList.indexOf(self.panelList[className]) < 0) {
                        this.createRoomWinodw._wanFaList.push(self.panelList[className]);
                    }
                }
                safeVisible(self.panelList[className], self.IsOn && self.isVisible());
            } else {
                var dependObject = self.getNode(self.parentNode, self.dependObjects[i]);
                safeVisible(dependObject, self.IsOn && self.isVisible());
            }
        }
        if (!self.IsOn)
            return;
        _.forIn(self.showObjects, function (showObject) {
            var showObjectObj = self.getNode(self.parentNode, showObject);
            safeVisible(showObjectObj, self.isVisible());
        });
        _.forIn(self.hideObjects, function (hideObject) {
            var hideObjectObj = self.getNode(self.parentNode, hideObject);
            safeVisible(hideObjectObj, false);
        });
    }
});